namespace Architecture.CrossCutting.LoggingEntities.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitDb : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.EFLogs",
                c => new
                    {
                        LogId = c.Guid(nullable: false),
                        CorrelationId = c.Guid(nullable: false),
                        EventIndex = c.Int(nullable: false),
                        EventName = c.String(),
                        Level = c.String(),
                        Operation = c.String(),
                        ProcessId = c.Int(nullable: false),
                        TaskName = c.String(),
                        ThreadId = c.Int(nullable: false),
                        CreationTime = c.DateTime(nullable: false),
                        ProviderName = c.String(),
                        Query = c.String(),
                        CommandType = c.String(),
                        Duration = c.Long(nullable: false),
                    })
                .PrimaryKey(t => t.LogId);
            
            CreateTable(
                "dbo.IISLogs",
                c => new
                    {
                        RequestId = c.Guid(nullable: false),
                        ssitename = c.String(name: "s-sitename"),
                        sip = c.String(name: "s-ip"),
                        csmethod = c.String(name: "cs-method"),
                        csuristem = c.String(name: "cs-uri-stem"),
                        csuriquery = c.String(name: "cs-uri-query"),
                        sport = c.String(name: "s-port"),
                        csusername = c.String(name: "cs-username"),
                        cip = c.String(name: "c-ip"),
                        csversion = c.String(name: "cs-version"),
                        csUserAgent = c.String(name: "cs-User-Agent"),
                        scstatus = c.Int(name: "sc-status", nullable: false),
                        scsubstatus = c.Int(name: "sc-substatus", nullable: false),
                        scwin32status = c.String(name: "sc-win32-status"),
                        scbytes = c.Long(name: "sc-bytes", nullable: false),
                        csbytes = c.Long(name: "cs-bytes", nullable: false),
                        timetaken = c.Int(name: "time-taken", nullable: false),
                    })
                .PrimaryKey(t => t.RequestId);
            
            CreateTable(
                "dbo.Logs",
                c => new
                    {
                        LogId = c.Guid(nullable: false),
                        CreationDate = c.DateTime(nullable: false),
                        ServiceName = c.String(maxLength: 128),
                        ComputerName = c.String(),
                        Function = c.String(),
                    })
                .PrimaryKey(t => t.LogId)
                .ForeignKey("dbo.ServiceDetail", t => t.ServiceName)
                .Index(t => t.ServiceName);
            
            CreateTable(
                "dbo.ServiceDetail",
                c => new
                    {
                        ServiceName = c.String(nullable: false, maxLength: 128),
                        Description = c.String(),
                    })
                .PrimaryKey(t => t.ServiceName);
            
            CreateTable(
                "dbo.WcfClientLogs",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        CorrelationId = c.Guid(nullable: false),
                        RequestDuration = c.Long(nullable: false),
                        TransportDuration = c.Long(nullable: false),
                        SerializationDuration = c.Long(nullable: false),
                        Started = c.DateTime(nullable: false),
                        Finished = c.DateTime(nullable: false),
                        RequestLength = c.Long(nullable: false),
                        ResponseLength = c.Long(nullable: false),
                        OperationName = c.String(),
                        Action = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.WebapiLogs",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Operation = c.String(),
                        Method = c.String(),
                        statusCode = c.String(),
                        Application = c.String(),
                        User = c.String(),
                        RequestIpAddress = c.String(),
                        RequestContentType = c.String(),
                        RequestUri = c.String(),
                        RequestMethod = c.String(),
                        RequestRouteTemplate = c.String(),
                        RequestRouteData = c.String(),
                        RequestHeaders = c.String(),
                        RequestSended = c.DateTime(),
                        ResponseContentType = c.String(),
                        ResponseStatusCode = c.Int(),
                        ResponseHeaders = c.String(),
                        ResponseReceived = c.DateTime(),
                        CorrelationId = c.Guid(nullable: false),
                        Level = c.Int(nullable: false),
                        Created = c.DateTime(nullable: false),
                        ThreadId = c.Int(nullable: false),
                        ProcessId = c.Int(nullable: false),
                        ServerName = c.String(),
                        ServerIp = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Logs", "ServiceName", "dbo.ServiceDetail");
            DropIndex("dbo.Logs", new[] { "ServiceName" });
            DropTable("dbo.WebapiLogs");
            DropTable("dbo.WcfClientLogs");
            DropTable("dbo.ServiceDetail");
            DropTable("dbo.Logs");
            DropTable("dbo.IISLogs");
            DropTable("dbo.EFLogs");
        }
    }
}
